import { Base64 } from "js-base64";
import CryptoJS from "crypto-js";

export default async (res = "", row) => {
  let orgrinUrl = row.remote_url.replace(/\\/g, "/");

  let orgrinUrls = `http://10.6.100.80:10002/Department/DownloadDepartmentFile?remote_url=${orgrinUrl}`;

  var previewUrl =
    orgrinUrls +
    `&fullfilename=${CryptoJS.MD5(row.file_name.split(".")[0]).toString()}.${
      row.file_name.slice(row.file_name.lastIndexOf('.')+1)
    }`;

  window.open(
    "http://10.6.100.80:8012/onlinePreview?url=" +
      encodeURIComponent(Base64.encode(previewUrl))
  );
};
